package com.niit.service.impl;

import com.niit.entity.Region;
import com.niit.repository.RegionRepository;
import com.niit.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegionServiceImpl implements RegionService {
	@Autowired
	private RegionRepository regionRepository;

	@Override
	public List<Region> findRegionByLevel(byte level) {
		return regionRepository.findAllByLevel(level);
	}

	@Override
	public List<Region> findRegionByParentCode(long parentCode) {
		return regionRepository.findAllByParentCode(parentCode);
	}

	@Override
	public Region findRegionById(long id) {
		return regionRepository.findById(id).orElse(null);
	}
}
